import 'package:flutter/material.dart';
import 'package:flutterApp/provider.dart/Devices.dart';
import 'package:provider/provider.dart';

class InputDeviceNo extends StatefulWidget {
  InputDeviceNo({Key key}) : super(key: key);

  @override
  _InputDeviceNoState createState() => _InputDeviceNoState();
}

class _InputDeviceNoState extends State<InputDeviceNo> {
  Widget _createPage() {
    return Container(
        padding: EdgeInsets.fromLTRB(10, 60, 10, 0),
        decoration: BoxDecoration(
          image: new DecorationImage(
            fit: BoxFit.fitWidth,
            alignment: Alignment.topLeft,
            image: AssetImage('images/bg-ellipse.png'),
          ),
        ),
        child: Container(
          padding: EdgeInsets.fromLTRB(10, 50, 10, 50),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.all(Radius.elliptical(5, 5)),
            boxShadow: [
              BoxShadow(
                  color: Colors.grey[200],
                  blurRadius: 2.0,
                  spreadRadius: 2.0),
            ],
          ),
          child: Column(children: [
            Row(children: [
              Expanded(
                child: TextField(
                  keyboardType: TextInputType.number,
                  decoration: InputDecoration(
                    contentPadding: const EdgeInsets.symmetric(
                        vertical: 10.0, horizontal: 10),
                    hintText: "请输入设备序列号",
                    border: OutlineInputBorder(
                        borderSide: BorderSide(color: Colors.blue)),
                    focusedBorder: OutlineInputBorder(
                        borderSide: BorderSide(color: Colors.blue)),
                    enabledBorder: OutlineInputBorder(
                      borderSide: BorderSide(
                        color: Colors.blue, // 边框颜色
                      ),
                    ),
                  ),
                ),
              ),
              Padding(
                padding: EdgeInsets.only(left: 10),
                child: ButtonTheme(
                  height: 47,
                  textTheme: ButtonTextTheme.primary,
                  child: RaisedButton(
                    child: new Text('确定'),
                    onPressed: () {
                      print("我点击确定");
                      Provider.of<Devices>(context, listen: false).set();
                      //Navigator.pushNamed(context, '/home');
                      Navigator.pushReplacementNamed(context, '/home');
                    },
                  ),
                ),
              )
            ]),
            SizedBox(height: 100),
            Image.asset("images/scan.png", width: 150.0),
            SizedBox(height: 15),
            Text("扫描设备条形码", style: TextStyle(color: Colors.grey))
          ]),
        ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("服务大厅"),
          centerTitle: true,
          // backgroundColor:Color(0xFF000000)
        ),
        body: SingleChildScrollView(child: this._createPage()));
  }
}
